<template>
	<view>
		<view class="box">
			<view class="cubar bg-white">
				<view class="border-title">
					<text class="text-xl text-bold">优惠券</text>
				</view>
			</view>
		</view>
		<view class="coupon text-grey box11 shadow" v-for="(item,index) in coupon.rows">
			<view class="coupon_left">
				<view class="coupon_left_top">
					{{item.couponName}}
				</view>
				<view class="coupon_left_buttom">
				</view>
			</view>
			<view class="coupon_right">
				<view class="coupon_right_top">
					<view class="coupon_right_top_left">
						{{item.showGrant}}
					</view>
					<view class="coupon_right_top_right">
						<!-- 尽可购买个人护理商品 -->
					</view>
				</view>
				<view class="text-red">
					积分：{{item.customer}}
				</view>
				<view class="coupon_right_buttom">
					<view class="">
						{{item.effectiveTime}}
					</view>
					<view class="coupon_right_buttom_button" @tap="exchange(item.id)">
						兑换
					</view>
				</view>
			</view>
		</view>
		<!-- 		<view class="box">
			<view class="cubar bg-white">
				<view class="border-title">
					<text class="text-xl text-bold">热门产品</text>
				</view>
			</view>
		</view>
		<view class="product_box">
			<view class="product" v-for="(item,index) in 5">
				<view class="product_left">
					商品1
				</view>
				<view class="product_buttom">
					<view class="product_buttom_top">
						<text class="text-red">特价：</text>
						<text class="text-grey  product_buttom_top_text">化妆品</text>
					</view>
					<view class="product_buttom_buttom text-red">
						<text>积分：</text>
						<text>10000</text>
					</view>
				</view>
			</view>
		</view> -->

	</view>
</template>

<script>
	import { mapState } from 'vuex'
	export default {
		data() {
			return {
				members: null, //会员id
				coupon: null, //优惠券
			}
		},
		onShow() {

		},
		onLoad(options) {
			this.member()
			this.couponList()
		},
		computed:{
			...mapState(['id'])
		},
		methods: {
			//获取会员id
			member() {
				const member = uni.getStorageSync('memberdata');
				this.members = member
			},
			couponList() {
				this.request.couponList().then(res => {
					this.coupon = res
				})
			},
			exchange(id) {
				this.request.exchange({
					oppenId: this.id,
					cpuponId: id
				}).then(res => {
					if (res.code == 0) {
						uni.showToast({
							icon: 'none',
							title: "兑换成功",
							content: "兑换成功"
						})
					}
					if (res.code == 500) {
						uni.showToast({
							icon: 'none',
							title: res.msg,
							content: res.msg
						})
					}

				})
			},

		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FFFFFF;
	}

	.box {
		border-bottom: 1rpx solid #F2F2F2;
	}

	.cubar {
		display: -webkit-box;
		display: -webkit-flex;
		display: flex;
		position: relative;
		-webkit-box-align: center;
		-webkit-align-items: center;
		align-items: center;
		min-height: 100rpx;
		-webkit-box-pack: justify;
		-webkit-justify-content: space-between;
		justify-content: center;
	}

	.coupon {
		padding: 10rpx 20rpx;
		display: flex;
		height: 190rpx;
	}

	.coupon_left {
		width: 178rpx;
		text-align: center;
		background-color: #39B54A;

		.coupon_left_top,
		.coupon_left_buttom {
			color: #FFFFFF;
			height: 50rpx;
			width: 178rpx;
			line-height: 150rpx;
		}

		.coupon_left_top {
			font-size: 30rpx;
			font-weight: 500;
		}

		.coupon_left_buttom {
			font-size: 24rpx;
		}
	}

	.coupon_right {
		padding: 15rpx 10rpx;
		margin-left: 10rpx;
		width: 572rpx;
		line-height: 56rpx;
		font-size: 24rpx;

		.coupon_right_top,
		.coupon_right_buttom {
			display: flex;
			justify-content: space-between;
		}

		.coupon_right_top {
			.coupon_right_top_left {
				width: 150rpx;
				height: 48rpx;
				line-height: 40rpx;
				text-align: center;
				color: #FFFFFF;
				background-color: #f37b1d;
				padding: 5rpx;
				border-radius: 25rpx;
			}
		}

		.coupon_right_buttom {
			.coupon_right_buttom_button {
				width: 150rpx;
				height: 48rpx;
				line-height: 40rpx;
				text-align: center;
				color: #f37b1d;
				border: 1rpx solid #f37b1d;
				padding: 5rpx;
				border-radius: 25rpx;
			}
		}
	}

	.product_box {
		display: flex;
		flex-wrap: wrap;

	}

	.product {
		width: 375rpx;

		.product_left {
			width: 356rpx;
			height: 300rpx;
			padding: 10rpx;
			margin: 10rpx;
			background-color: #007AFF;
		}
	}

	.product_buttom {

		.product_buttom_top,
		.product_buttom_buttom {
			font-size: 20rpx;
			margin: 10rpx;

			.product_buttom_top_text {
				font-size: 23rpx;
			}
		}
	}

	.box11 {
		height: 100px;
		background: #FFFFFF;
		border-radius: 10px;
		margin: 10px;
	}

	.shadow {
		position: relative;
		box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.3),
			0px 0px 20px rgba(0, 0, 0, 0.1) inset;
	}

	.shadow::before,
	.shadow::after {
		content: "";
		position: absolute;
		z-index: -1;
	}

	.shadow::before,
	.shadow::after {
		content: "";
		position: absolute;
		z-index: -1;
		bottom: 15px;
		left: 10px;
		width: 50%;
		height: 20%;
	}

	.shadow::before,
	.shadow::after {
		content: "";
		position: absolute;
		z-index: -1;
		bottom: 15px;
		left: 10px;
		width: 50%;
		height: 20%;
		box-shadow: 0 15px 10px rgba(0, 0, 0, 0.7);
		transform: rotate(-3deg);
	}

	.shadow::after {
		right: 10px;
		left: auto;
		transform: rotate(3deg);
	}
</style>
